<template>
  <div>
    <Order
      :option="option"
      :dataList="dataList"
      :list="list"
      :page="page"
      @search="search"
      @pagination="paginationChange"
    ></Order>
  </div>
</template>

<script setup>
import { useStore } from "@/store/index.js"; //将之前配置的pinia文件夹中的index.js文件引入
import { storeToRefs } from "pinia";
import { onMounted, ref } from "vue";
import { defaultAxios } from "@/utils/request";
import Order from "@/components/Order.vue";
let store = useStore(); //接收
let dataList = ref([]);
let list = ref([]);
// const form = true;
const page = ref({
  total: 10,
  pageSize: 10,
  currentPage: 1,
  layout: "total, sizes, pager,pre,next,jumper",
});
let text = ref(false);
let option = ref({
  align: "left",
  menuAlign: "center",
  addBtn: false,
  emptyBtn: false,
  column: [
    {
      label: "订单信息",
      prop: "orderInfo",
      search: false,
    },
    {
      label: "车次/类型",
      prop: "trainType",
      search: false,
    },
    {
      label: "出发站/到达站",
      prop: "station",
      search: false,
    },
    {
      label: "出发/到达时间",
      prop: "time",
      search: false,
    },
    {
      label: "乘车人/出发日期",
      prop: "date",
      search: false,
    },
    {
      label: "票价/车厢座号/坐席类型",
      prop: "seatInfo",
      search: false,
    },
    {
      label: "状态",
      prop: "state",
      search: false,
    },
  ],
});
onMounted(() => {
  defaultAxios.get("/order").then((res) => {
    console.log(res);
    page.value.total = res.list.length;
    dataList.value = res.list.slice(0, 10);
    list.value = res.list;
  });
});
const paginationChange = (obj) => {
  page.currentPage = obj.CurrentPage;
  dataList.value = obj.Page;
};
const search = (obj) => {
  console.log(obj);
  dataList.value = obj;
};
</script>

<style scoped></style>
